<include file="public@header" />
<style type="text/css">
    /*.form-search label{width:300px;}*/
    /*.form-search label.date{width:300px;}*/
    /*.form-search input.js-date{width:80px;}*/
    /*.form-search select{width:auto !important;}*/
    /*.groups{overflow:hidden; width:46%; border-right:1px double #0b7ebf; float:left; margin-bottom:50px; padding:4%;}*/
    /*.groups1{overflow:hidden; width:45%; float:left}*/
    /*.control-group{!*width:95%; margin:5px 5% 5px 0; overflow:hidden; border-bottom:1px dashed #eee*! }*/
    /*.control-group1{width:90%; margin:10px 5%; overflow:hidden; border-bottom:1px dashed #eee}*/
    /*.control-group label{ width:50%; float:left}*/

    /*.control-group1 label{ width:100%; float:left}*/
    /*.form-horizontal .control-group1 {*/
    /*    float: left;*/
    /*    width: 15%;*/
    /*    margin-bottom: 20px;*/
    /*}*/
    .form-horizontal .control-label {width:105px;}
    /*.form-horizontal .controls {margin-left:90px;}*/
    /*input,select, textarea, .uneditable-input {*/
    /*    max-width: 100px;*/
    /*    width:auto;*/
    /*    min-width:60px;*/
    /*}*/

    /*.tom .form-group .control-label{*/
    /*    max-width: 100px;*/
    /*    width:auto;*/
    /*}*/
    .tom .form-group .form-control{
        width:auto;
    }
    input{ width:auto;}
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('orders/visua')}">可视化墓区</a></li>
        <li class="active"><a href="">格位信息</a></li>
    </ul>
    <form  class="form-horizontal js-ajax-form" method="post" action="{:url('Orders/sale')}" enctype="multipart/form-data" style="width:80%;float:left;">
        <fieldset>
            <div class="p_title">
                <span class="span_title">格位详情</span>
            </div>
            <div class="control-group1-p tom" style="border:1px solid #e2e2e2; padding-top:20px;">
                <div class="form-group">
                    <label class="control-label">壁式:</label>
                    <div class="col-md-2">
                        <select class="form-control" name="tomb[funeral]"  >
                            <foreach name="tomb_funeral.jd" item="vo">
                                <option value="{$vo}" <if condition="$vo eq  $result['funeral'] ">selected </if>>{$vo}</option>
                            </foreach>
                        </select>
                    </div>
                    <label class="control-label">空间长度:</label>
                    <div class="col-md-2">
                        <input type="text" class="form-control" name="footprint" style="width: 100px;" value="{$result.footprint|default=''}"  disabled>mm
                    </div>
                    <label class="control-label">空间宽度:</label>
                    <div class="col-md-2">
                        <input type="text" class="form-control" name="tombstone_w" style="width: 100px;"value="{$result.tombstone_w|default=''}" disabled >mm
                    </div>
                    <label class="control-label">空间高度:</label>
                    <div class="col-md-2">
                        <input type="text" class="form-control" name="tombstone_h" style="width: 100px;"value="{$result.tombstone_h|default=''}" disabled >mm
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">所在层数:</label>
                    <div class="col-md-2">
                        <input type="text" class="form-control" name="layer_num" value="{$result.layer_num|default=''}"  disabled>
                    </div>
                    <label class="control-label">墓穴规制:</label>
                    <div class="col-lg-2">
                        <select class="form-control" name="tomb_regulation" disabled >
                            <foreach name="tomb_regulation" item="vo">
                                <option value="{$vo.id}" <if condition="$vo.id eq  $result['tomb_regulation'] ">selected </if>>{$vo.name}</option>
                            </foreach>
                        </select>
                    </div>
                    <label class="control-label">收敛形式:</label>
                    <div class="col-md-2">
                        <select class="form-control" name="tomb[convergence]"  >
                            <foreach name="tomb_convergence.jd" item="vo">
                                <option value="{$vo}" <if condition="$vo eq  $result['convergence'] ">selected </if>>{$vo}</option>
                            </foreach>
                        </select>
                    </div>
                    <label class="control-label ">售后质保期:</label>
                    <div class="col-md-2">
                        <select class="form-control" name="warranty"  disabled>
                            <option value="3" >购买起计3年</option>
                        </select>
                    </div>
                </div>

                <div class="form-group  ">
                    <label class="control-label">墓穴维护期:</label>
                    <div class="col-md-2">
                        <select class="form-control" name="maintain"  disabled>
                            <option value="20" >首位安葬起20年</option>
                        </select>
                    </div>
                    <label class="control-label">抵顶人:</label>
                    <div class="col-md-2">
                        <input type="text" class="form-control" name="substitute" value="{$result.substitute|default=''}" disabled>
                    </div>
                    <label class="control-label">类型:</label>
                    <div class="col-md-2">
                        <select class="form-control"  disabled >
                            <option value="4" >节地墓</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="p_title">
                <span class="span_title">订单详情</span>
                <input type="hidden" name="order[order_id]" value="{$result.order_id|default=''}">
                <input type="hidden" name="order[tomb_product_id]" value="{$result.id}">
                <input type="hidden" name="order[tomb_type]" value="{$cate_id}">
                <input type="hidden" name="order[tomb_id]" value="{$result.colID|default=''}">
                <input type="hidden" name="order[tomb_num]" value="{$result.num|default=''}">
                <input type="hidden" name="order[orders_id]" value="{$orders_id|default=''}">
            </div>
            <div class="control-group1-p" style="border:1px solid #e2e2e2; padding-top:20px;">
                <div class="form-group">
                    <label class="control-label">格位编号</label>
                    <div class="col-md-2">
                        <input type="text"  class="form-control" style="width: 100%" disabled value="{$result.num|default=''}">
                    </div>
                    <label class="control-label">所在区域</label>
                    <div class="col-md-2">
                        <input type="text" name="tomb_region" class="form-control" value="{$result.tomb_region|default=''}" disabled>
                    </div>
                    <label class="control-label">所在位置</label>
                    <div class="col-md-2">
                        <input type="text" name="tomb_address" class="form-control" value="{$result.tomb_address|default=''}" disabled>
                    </div>
                    <label class="control-label">所在层数</label>
                    <div class="col-md-2">
                        <input type="text" name="layer_num" class="form-control" value="{$result.layer_num|default=''}" disabled>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">所在位号</label>
                    <div class="col-md-2">
                        <input type="text" name="tomb_bit_number" class="form-control" value="{$result.tomb_bit_number|default=''}" disabled>
                    </div>
                    <label class="control-label">销售价格</label>
                    <div class="col-md-2">
                        <input type="hidden" class="selling_price"  name="order[selling_price]" value="{$result.selling_price|default='0'}">
                        <input type="text"  class="form-control selling_price" value="{$result.selling_price|default=''}" disabled >
                    </div>
                    <label class="control-label">折扣让利</label>
                    <div class="col-md-2">
                        <input type="hidden" class="form-control "  id="discount_ratio_"  name="order[discount_ratio]" value="{$result.discount_ratio|default='0'}">
                        <select  style="width: 90%" class="form-control discount_ratio">
                            <for start="0" end="20" step="5" >
                                <if condition="isset($result['discount_ratio'])">
                                    <option value="{$i/100}" <if condition="($i/100) eq  $result['discount_ratio'] ">selected </if>>{$i}%</option>
                                    <else/>
                                    <option value="{$i/100}">{$i}%</option>
                                </if>
                            </for>
                        </select>
                    </div>
                    <label class="control-label"style="">免零金额</label>
                    <div class="col-md-2" style=" ">
                        <input type="text" name="order[free_price]" class="form-control free_price" value="{$result.free_price|default='0'}" <if condition="$result.reacher">disabled <else/>    </if> >
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">成交价格 </label>
                    <div class="col-md-2">
                        <input type="hidden" class=" closing_price"   name="order[closing_price]" value="{$result.closing_price|default='0'}">
                        <input type="text" class="form-control closing_price"    value="{$result.closing_price|default='0'}" disabled>
                    </div>
                    <label class="control-label">下单时间</label>
                    <div class="col-md-2">
                        <input type="hidden"   name="add_time" value="{$result.add_order_time}"   >
                        <input type="text" class="form-control js-date" name="add_time" value="{$result.add_order_time}" disabled >
                    </div>
                    <label class="control-label">导购员</label>
                    <div class="col-md-2">
                        <input type="hidden"   name="order[shoppingguide]" value="{$result.shoppingguide}" >
                        <input type="text" class="form-control" name="shoppingguide" disabled value="{$result.shoppingguide_name}">
                    </div>
                    <label class="control-label" style="width:100px">代理商</label>
                    <div class="col-md-2" style=" ">
                        <select name="order[agent_user]"  style="width: 100%"  class="form-control">
                            <option value="0">请选择</option>
                            <foreach name="dailishang_list" item="vou">
                                <if condition=" isset($result['agent_user'])">
                                    <option value="{$vou.id}" <if condition=" $result['agent_user'] eq $vou.id"> selected </if>>{$vou.department_name}-{$vou.user_nickname}</option>
                                    <else/>
                                    <option value="{$vou.id}">{$vou.department_name}-{$vou.user_nickname}</option>
                                </if>
                            </foreach>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">抵顶人</label>
                    <div class="col-md-2">
                        <input type="text" class="form-control" name="reaching" value="{$result.reacher|default=''}" disabled >
                    </div>
                    <label class="control-label">经办人</label>
                    <div class="col-md-2">
                        <input type="hidden"   name="order[handle]" value="{$result.handle|default=''}" >
                        <input type="text" style="width: 100%" class="form-control" name="handle" value="{$result.handle_name|default=''}" disabled>
                    </div>
                </div>
            </div>
        </fieldset>
        <div class="form-actions" style="clear:both;">
            <!--        <div class="btn btn-primary " id="check-btn">下一步</div>-->
            <button type="submit" class="btn btn-primary js-ajax-submit">下一步</button>
        </div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
<script>

    $(function () {
        $('.discount_ratio').val(1- $('#discount_ratio_').val())
        var discount_ratio =  $('#discount_ratio_'),//  折扣
            selling_price =  $('.selling_price'),// 销售金额
            free_price = $('.free_price'),//
            closing_price = $('.closing_price');// 成交价
        if (discount_ratio.val()==0){
            closing_price.val(parseFloat(selling_price.val()-free_price.val()).toFixed(2))
        }else {
            closing_price.val(parseFloat((selling_price*(1-discount_ratio.val()))-free_price.val()).toFixed(2));
        }
    })

    $('.discount_ratio').change(function () {
        $('#discount_ratio_').val(1-$(this).val())
        var free_price  = $('.free_price').val(),
           discount_ratio = $('#discount_ratio_').val(),
           selling_price = $('.selling_price').val();

        var receivable_price =  selling_price-free_price;
        if (discount_ratio!=0){
            receivable_price =  (discount_ratio*selling_price)-free_price;
        }
        $(".closing_price").val(receivable_price.toFixed(2));
    })

    $('.free_price').blur(function () {
        var free_price  = $(this).val();
        if(free_price >= 100){
            layer.msg('减免金额不能超过100元');
        }else {
            var discount_ratio = $('#discount_ratio_').val(),
                selling_price =  $('.selling_price').val();
            var receivable_price =  selling_price-free_price;
            if (discount_ratio!=0){
                receivable_price =  (discount_ratio*selling_price)-free_price;
            }
            $(".closing_price").val(receivable_price.toFixed(2));
        }
    })



</script>
</body>
</html>